import redis
# import time

r = redis.Redis(host='127.0.0.1', port=6379, db=0)


result = r.keys('*')

# list01 = []
# for r in result:
#     list01.append(r.decode())
#
# print(list01)

print([i.decode() for i in result])

r.set("sms_17685457791", 871016, ex=3)
# time.sleep(4)
result = r.get("sms_17685457791")
if not result:
    print("验证码已经过期，请重新获取")
else:
    print(int(result.decode()))

r.mset({"index_cache": "index", "detail_cache": "detail"})
result = r.mget(["index_cache", "detail_cache"])
print([i.decode() for i in result])

result = r.delete("index_cache")
print(result)

r.lpush("spider", 'task', 'view')
result = r.lrange("spider", 0, -1)
print(result)

result = r.brpop('spider', 3)
print(result)

